<%@ include file="/common/taglibs.jsp"%>

<head>
<title><fmt:message key="birthCertificate.title" /></title>

<script type="text/javascript">

function printPage()
{
	window.print();
}

function openNewWindow()
{
	window.open('${ctx}/print/printBirthReceipt?id=${id}'  , "Print Receipt", "menubar=0,status=0,width=950,height=500");
}

function viewIdProof()
{
	window.open('${ctx}/print/viewIdProof?id=${id}', "Photo ID Proof", "menubar=0,status=0,width=800,height=600");
}
function confirmComment(theForm) {
	mystring=document.getElementById('rejCom').value; 
	if(!mystring.match(/\S/)){
		alert ('Please provide the reason of rejection in the comment section to proceed.');
		return false;
	}
	 return true;

}
function confirmRegistrationNumber(obj) {
	mystring=document.getElementById('regNum').value; 
	if(!mystring.match(/\S/)){
		alert ('Please provide the registration number before approving this birth.');
		return false;
	}
	 return true;
}
</script>

<style type="text/css">
div.two_col_left_box {
	float: left;
	padding: 0px;
	width: 380px;
	border: 0px solid gray;
	font-family: "HelveticaNeue-Light", "Helvetica Neue Light",
		"Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
	font-weight: 300;
}

div.two_col_right_box {
	float: right;
	padding: 0px;
	width: 380px;
	border: 0px solid gray;
}

div.three_col_left_box {
	float: left;
	padding: 0px;
	width: 270px;
	border: 0px solid gray;
}

div.three_col_mid_box {
	float: left;
	padding: 0px;
	width: 270px;
	border: 0px solid gray;
}

div.three_col_right_box {
	float: left;
	padding: 0px;
	width: 270px;
	border: 0px solid gray;
}

div.form_row {
	width: 840px;
	padding: 1px;
	overflow: hidden;
	border: 0px solid gray;
	font-family: verdana;
	padding: 10px;
}

div.section_header {
	width: 840px;
	height: 26px;
	color: #FFFAFA;
	display: table-cell;
	vertical-align: middle;
	background-color: #545454;
	padding: 0 5px 2px;
	font-family: serif;
	font-size: 14px;
}
</style>
</head>

<body class="viewBirth" />

<div class="span12">
	<s:form name="viewBirthForm" action="createBirth.action"
		enctype="multipart/form-data" method="post" validate="false"
		cssClass="well form-vertical">

		<%-- 		<s:param name="id">   --%>
		<%--                 <s:property value="id" />   --%>
		<%--         </s:param>   --%>

		<s:hidden key="birth.id" />
		<s:hidden key="zoneId" />
		<s:hidden key="id" />
		<input type="hidden" name="from" value="${param.from}" />

		<div id="birthDetails" class="section_header">
			<b>BIRTH INFORMATION</b>
		</div>

		<div class="form_row">
			<div class="three_col_left_box">
				<b> Reference No. : 
				<s:property value="%{birth.id}" /> </b>
				
			</div>

			<div class="three_col_mid_box">
				<b> Mother Name: </b>
				<s:property value="%{birth.motherName}" />
			</div>

			<div class="three_col_right_box">
				<b> Father Name: </b>
				<s:property value="%{birth.fatherName}" />
			</div>
		</div>

		<div class="form_row">
			<div class="three_col_left_box">
				<b>Birth Date : </b>
				<s:property value="%{birth.birthDateString}" />
			</div>

			<div class="three_col_mid_box">
				<b> Mobile Number : </b>
				<s:property value="%{birth.mobileNumber}" />
			</div>

			<div class="three_col_right_box">
				<b> e-mail Id : </b>
				<s:property value="%{birth.email}" />
			</div>
		</div>

		<div class="form_row" id="child_info_1">
			<div class="three_col_left_box">
				<b> Child Name : </b>
				<s:property value="%{birth.childName}" />
			</div>

			<div class="three_col_mid_box">
				<b> Sex : </b>
				<s:property value="%{birth.sex}" />
			</div>

			<div class="three_col_right_box">
				<b> Birth weight (in kgs.) : </b>
				<s:property value="%{birth.birthWeight}" />
			</div>
		</div>

		<div class="section_header">
			<b>PARENT INFORMATION</b>
		</div>
		<div class="form_row">
			<div class="three_col_left_box">
				<b> Name of Place : </b>
				<s:property value="%{birth.residencePlaceName}" />

			</div>

			<div class="three_col_mid_box">
				<b> Place Type : </b>
				<s:property value="%{birth.residencePlaceType}" />
			</div>

			<div class="three_col_right_box">
				<b> District : </b>
				<s:property value="%{birth.district}" />
			</div>
		</div>

		<div class="form_row">
			<div class="three_col_left_box">
				<b> State : </b>
				<s:property value="%{birth.state}" />
			</div>

			<div class="three_col_mid_box">
				<b> Father's Education : </b>
				<s:property value="%{birth.fatherEducation}" />
			</div>

			<div class="three_col_right_box"></div>
		</div>

		<div class="form_row">
			<div class="three_col_left_box">
				<b> Religion :</b>
				<s:property value="%{birth.familyReligion}" />
			</div>

			<div class="three_col_mid_box">
				<b> Mother's Education :</b>
				<s:property value="%{birth.motherEducation}" />
			</div>

			<div class="three_col_right_box">
				<b> Father Occupation : </b>
				<s:property value="%{birth.fatherOccupation}" />
			</div>
		</div>
		<div class="section_header">
			<b>OTHER INFORMATION</b>
		</div>

		<div class="form_row">
			<div class="three_col_left_box">
				<b> Mother age at Marriage : </b>
				<s:property value="%{birth.motherAgeAtMarriage}" />
			</div>

			<div class="three_col_mid_box">
				<b> Mother age on child birth : </b>
				<s:property value="%{birth.motherAgeOnChildBirth}" />
			</div>

			<div class="three_col_right_box">
				<b> Number of alive children : </b>
				<s:property value="%{birth.numberOfAliveChildren}" />
			</div>
		</div>
		<div class="form_row">
			<div class="three_col_left_box">
				<b> Attention Type : </b>
				<s:property value="%{birth.attentionType}" />
			</div>

			<div class="three_col_mid_box">
				<b> Delivery method : </b>
				<s:property value="%{birth.deliveryMethod}" />
			</div>

			<div class="three_col_right_box">
				<b> Pregnancy Duration (in weeks): </b>
				<s:property value="%{birth.pregnancyDuration}" />
			</div>
		</div>
		<div class="form_row">
			<div class="three_col_left_box">
				<s:if test="birth.idProof != null">
					<img
						src="showImage.action?id=<s:property value="birth.id"/>&from=list"
						border="0" width="100" height="100">
				</s:if>
			</div>

			<div class="three_col_mid_box"></div>

			<div class="three_col_right_box"></div>
		</div>
		
		<s:if test="birth.idProof != null">
			<s:a href="#" onclick="viewIdProof(); return false;">View Id Proof</s:a>
		</s:if> 

		<security:authorize ifAllGranted="ROLE_ZONE_BIRTH">
			<c:if test="${(birth.status == 'Submit')}">
				<!-- panel -->
				<div class="section_header">
				   <b>APPROVAL SECTION</b>
				</div>
				<div class="form_row">
					<div class="three_col_left_box">
						<s:textfield id="regNum" key="birth.registrationNumber" required="true" />
					</div>
				   
				   <div class="three_col_mid_box">
						<s:textarea id="rejCom" key="birth.comment" required="true" />
					</div>
				   
					<div class="three_col_right_box">
					<b>Comments:</b>
					 <s:iterator value="birth.comments" var="row" status="status">
                    	
                    	 </br><s:property value="createdOn"/> - <s:property value="comments"/>
                	</s:iterator>
                
						<c:forEach items="${birthTypeList}" var="list1">
							<s:property value="%{list1}" />
					    </c:forEach>
					</div>
				 </div>
				<!-- end panel -->
			</c:if>
			</security:authorize>
		<%-- 		<s:url id="idProof" action="/print/printBirthReceipt"> <s:param name="id" value="id"/> </s:url> <s:a href="http://localhost:8080/nmcbd/print/printBirthReceipt?id=%{id}" onclick="window.open(this.href);return false;">View Id Proof</s:a> --%>
		
		
		<security:authorize ifAllGranted="ROLE_HOSPITAL">
			<fieldset class="form-actions">
				<input type="button" class="btn btn-primary" onClick='openNewWindow()' value="Print"/>
				<security:authorize ifAllGranted="ROLE_HOSPITAL">
					<c:if
						test="${(birth.status == 'Draft' or birth.status == 'Rejected')}">
						<s:submit key="button.edit" cssClass="btn btn-primary"
							theme="simple" method="editRecord" />
					</c:if>
				</security:authorize>
				<s:submit key="button.cancel" method="cancel" cssClass="btn"
					theme="simple" />
			</fieldset>
		</security:authorize>
		
		<security:authorize ifAllGranted="ROLE_ZONE_BIRTH">
			<fieldset class="form-actions">
				<c:if test="${(birth.status == 'Submit')}">
					<s:submit key="button.approve" action="approveBirth"
						onclick="return confirmRegistrationNumber(this);" cssClass="btn btn-primary" theme="simple" />
					<s:submit key="button.reject" action="rejectBirth"
						onclick="return confirmComment(this);" cssClass="btn btn-primary" theme="simple" />
				</c:if>
				<s:submit key="button.cancel" method="cancel" cssClass="btn"
					theme="simple" />
			</fieldset>
		</security:authorize>
			
	</s:form>

</div>

